import time

from selenium.webdriver.common.by import By

from Pages import BasePage

class OrderListPage(BasePage.Action):

    def __init__(self):
        #订单中心
        self.orderList_xpath = (By.XPATH,"//li[text()='订单中心']")
        #输入订单号
        self.inputOrderNo_xpath = (By.XPATH,"//input[@placeholder='请输入订单号']")
        #
        self.searchButton_xpath = (By.XPATH, "//button[@class='search-btn']")
        #
        self.orderItem_xpath = (By.XPATH, "//div[@class='lst-item']//div[contains(@class,'order-item')]")


    def goOrderDetail(self):
        self.find_elements(*self.orderItem_xpath)[0].click()
        time.sleep(3)

    def selectOrder(self, orderNo):
        self.find_element(*self.inputOrderNo_xpath).send_keys(orderNo)
        time.sleep(1)
        self.find_element(*self.searchButton_xpath).click()
        time.sleep(3)
        self.goOrderDetail()
        self.switch_window()


